package com.wwtech.epp.ui.adapter.work;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wwtech.epp.R;
import com.wwtech.epp.entity.ProjectTask;
import com.wwtech.epp.view.GlideCircleTransform;

import java.util.List;

/**
 * 作者：Android on 2017/9/2
 * 邮箱：365941593@qq.com
 * 描述：
 */

public class ProjectTaskAdapter extends BaseQuickAdapter<ProjectTask, BaseViewHolder> {

    public ProjectTaskAdapter(@Nullable List<ProjectTask> data) {
        super(R.layout.project_task_item, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ProjectTask projectTask) {
        baseViewHolder.addOnClickListener(R.id.iv_avater);
        baseViewHolder.addOnClickListener(R.id.tv_end_time);
        baseViewHolder.addOnClickListener(R.id.tv_task_desc);
        baseViewHolder.setText(R.id.tv_task_desc, projectTask.getDiscrab());
        baseViewHolder.setText(R.id.tv_end_time, projectTask.getEndTime());
        ImageView iv_avater = baseViewHolder.getView(R.id.iv_avater);
        if (projectTask.getPartPerson() != null && projectTask.isCheck()) {
            projectTask.setCheck(true);
            Glide.with(mContext)
                    .load(projectTask.getPartPerson().getAvatar())
                    .transform(new GlideCircleTransform(mContext))
                    .into(iv_avater);
            baseViewHolder.setText(R.id.name, "(" + projectTask.getPartPerson().getNickname() + ")");
        } else {
            projectTask.setCheck(false);
            Glide.with(mContext)
                    .load(R.mipmap.work_add)
                    .transform(new GlideCircleTransform(mContext))
                    .into(iv_avater);
            baseViewHolder.setText(R.id.name, "");
        }
    }
}
